
module siopmp_top(
input            siopmp_m2s_ahb_hclk          ,
input            siopmp_m2s_ahb_hrst_b        ,
input [31:0]     siopmp_m2s_ahb_haddr_i       ,
input [2 :0]     siopmp_m2s_ahb_hburst_i      ,
input [3 :0]     siopmp_m2s_ahb_hprot_i       ,
input            siopmp_m2s_ahb_hsel_i        ,
input [2 :0]     siopmp_m2s_ahb_hsize_i       ,
input [1 :0]     siopmp_m2s_ahb_htrans_i      ,
input [31:0]     siopmp_m2s_ahb_hwdata_i      ,
input            siopmp_m2s_ahb_hwrite_i      ,
         
input [31:0]     siopmp_s2m_ahb_hrdata_i      ,
input            siopmp_s2m_ahb_hready_i      ,
input [1 :0]     siopmp_s2m_ahb_hresp_i       ,
      
input            siopmp_reg_clk_i             ,
input            siopmp_reg_rstn_i            ,
input            siopmp_cfg_en_i              , 
input [7:0]      siopmp_reg_addr_i            ,
input            siopmp_reg_wen_i             ,
input            siopmp_reg_ren_i             ,   
input [31:0]     siopmp_reg_wdata_i          ,  
output[31:0]     siopmp_rddata_o              ,
 
output [31 : 0]  siopmp_m2s_ahb_check_haddr_o ,
output [2 : 0]   siopmp_m2s_ahb_check_hburst_o,
output [3 : 0]   siopmp_m2s_ahb_check_hprot_o ,
output           siopmp_m2s_ahb_check_hsel_o  ,
output [2 : 0]   siopmp_m2s_ahb_check_hsize_o ,
output [1 : 0]   siopmp_m2s_ahb_check_htrans_o,
output [31 : 0]  siopmp_m2s_ahb_check_hwdata_o,
output           siopmp_m2s_ahb_check_hwrite_o,
 
output [31 : 0]  siopmp_s2m_ahb_check_hrdata_o,
output           siopmp_s2m_ahb_check_hready_o,
output [1 : 0]   siopmp_s2m_ahb_check_hresp_o ,
output           siopmp_s2m_ahb_check_intr_o  
);


wire [31 : 0]                rg2ck_rule      ;
wire                         ctl2ckrg_checkwen   ;
wire                         ck2rg_error_flag;
wire [15:0]                  ck2rg_error_hit ;  
wire                         ck2ctl_hwren     ;
wire                         ck2ctl_hrden     ;
wire                         ck2ctl_hrdy      ;                  
wire                         rg2ctl_cfgen    ;
// wire                         ctl2rg_cfgdone  ;
wire[3:0]                    ctl2ck_state_n   ;

siopmp_check u_siopmp_check(
    .siopmpck_clk_i            (siopmp_m2s_ahb_hclk       ),
    .siopmpck_rst_n_i          (siopmp_m2s_ahb_hrst_b     ),
    // from siopmp_reg
    .siopmpck_rule_i           (rg2ck_rule              ),
    // from siopmp_control
    .siopmpck_check_en_i       (ctl2ckrg_checkwen           ),
    .siopmpck_state_n_i        (ctl2ck_state_n           ),
    

    //from master
    .siopmpck_haddr_i          (siopmp_m2s_ahb_haddr_i        ),
    .siopmpck_hburst_i         (siopmp_m2s_ahb_hburst_i       ),
    .siopmpck_hprot_i          (siopmp_m2s_ahb_hprot_i        ),       //hprot[0]婵犵數鍋為崹鍫曞箹椤愶箑绠柨鐕傛嫹0闂傚倷鐒︾€笛呯矙閹寸偟闄勯柡鍐ㄧ墕閼歌銇勯幒鎴濃偓褰掑磻濮椻偓閺屾洘绻濊箛娑欘€嶇紒妤佸灴濮婃椽宕崟鍨ら梺绋垮閹稿啿鐣烽棃娑栤偓鎺椼€傛刊蹇涙⒒娴ｅ湱婀介柛鏂跨灱閳ь剚鍑归崹鍫曘€佸▎鎾冲唨妞ゆ挾鍟块幏璇差渻閵堝棙顥嗘い鏂匡功閹广垽宕卞☉娆戝幈濠电偛妫楃换鎰枔閳哄啰纾奸弶鍫涘妿缁犳牜绱掔€ｎ亶妯€闁轰焦鎹囬弫鎾绘晸閿燂拷1闂傚倷鐒︾€笛呯矙閹寸偟闄勯柡鍐ㄧ墕閼歌銇勯幒鎴濃偓褰掑磻濮椻偓閺屾洘绻濊箛娑欘€嶇紒妤佸灴濮婃椽宕崟鍨ら梺绋垮閹稿啿鐣烽棃娑栤偓鎺楁倵瀹勭偤姊绘担鍦菇闁告柨鐬奸埀顒佸嚬閸ㄥ爼銆佸▎鎾冲唨妞ゆ挾鍟块幏璇差渻閵堝棙顥嗘い鏂匡功閹广垽宕卞☉娆戝幈濠电偛妫欓悷锔锯偓姘炬嫹
    .siopmpck_hsel_i           (siopmp_m2s_ahb_hsel_i         ),
    .siopmpck_hsize_i          (siopmp_m2s_ahb_hsize_i        ),
    .siopmpck_htrans_i         (siopmp_m2s_ahb_htrans_i       ),
    .siopmpck_hwdata_i         (siopmp_m2s_ahb_hwdata_i       ),
    .siopmpck_hwrite_i         (siopmp_m2s_ahb_hwrite_i       ),
    //from slave
    .siopmpck_hrdata_i         (siopmp_s2m_ahb_hrdata_i       ),
    .siopmpck_hready_i         (siopmp_s2m_ahb_hready_i       ),
    .siopmpck_hresp_i          (siopmp_s2m_ahb_hresp_i        ),
    .siopmpck_intr_i           (1'b0                         ),

   //to slave
    .siopmpck_haddr_o          (siopmp_m2s_ahb_check_haddr_o ),
    .siopmpck_hburst_o         (siopmp_m2s_ahb_check_hburst_o),
    .siopmpck_hprot_o          (siopmp_m2s_ahb_check_hprot_o ), 
    .siopmpck_hsel_o           (siopmp_m2s_ahb_check_hsel_o  ),
    .siopmpck_hsize_o          (siopmp_m2s_ahb_check_hsize_o ),
    .siopmpck_htrans_o         (siopmp_m2s_ahb_check_htrans_o),
    .siopmpck_hwdata_o         (siopmp_m2s_ahb_check_hwdata_o),
    .siopmpck_hwrite_o         (siopmp_m2s_ahb_check_hwrite_o),
    //to master
    .siopmpck_hrdata_o         (siopmp_s2m_ahb_check_hrdata_o),
    .siopmpck_hready_o         (siopmp_s2m_ahb_check_hready_o),
    .siopmpck_hresp_o          (siopmp_s2m_ahb_check_hresp_o ),
    .siopmpck_intr_o           (siopmp_s2m_ahb_check_intr_o  ),
    //to siopmp_reg
    .siopmpck_error_o          (ck2rg_error_flag         ),
    .siopmpck_iohit_o          (ck2rg_error_hit           ),
    //to siopmp_control
    .siopmpck_hwren_o          (ck2ctl_hwren              ),
    .siopmpck_hrden_o          (ck2ctl_hrden              ),
    .siopmpck_hrdy_o           (ck2ctl_hrdy               )
);


siopmp_control u_siopmp_control(
    .siopmpctl_clk_i           (siopmp_m2s_ahb_hclk        ),
    .siopmpctl_rst_n_i         (siopmp_m2s_ahb_hrst_b      ),
        
    .siopmpctl_cfgen_i         (rg2ctl_cfgen             ),        

    .siopmpctl_hwren_i         (ck2ctl_hwren              ),
    .siopmpctl_hrden_i         (ck2ctl_hrden              ),
    .siopmpctl_hready_i        (ck2ctl_hrdy               ),
     
    .siopmpctl_check_en_o      (ctl2ckrg_checkwen         ), 
    .siopmpctl_state_n_o       (ctl2ck_state_n            )
    // .siopmpctl_cfgdone_o       (ctl2rg_cfgdone           )
);













siopmp_reg #(1)
u_siopmp_reg(
    .siopmprg_clk_i       (siopmp_reg_clk_i    ),
    .siopmprg_rst_n_i     (siopmp_reg_rstn_i   ),
    .siopmprg_en_i        (siopmp_cfg_en_i    ),
    .siopmprg_wen_i       (siopmp_reg_wen_i   ),
    .siopmprg_ren_i       (siopmp_reg_ren_i   ),
    .siopmprg_addr_i      (siopmp_reg_addr_i  ),
    .siopmprg_wdat_i      (siopmp_reg_wdata_i),

    .siopmprg_access_ill_i(ck2rg_error_flag     ),
    .siopmprg_hit_i       (ck2rg_error_hit      ),

    .siopmprg_cfgwen_i    (ctl2ckrg_checkwen    ),

    .siopmprg_rdat_o      (siopmp_rddata_o      ),
    .siopmprg_cfgen_o     (rg2ctl_cfgen         ),
    .siopmprg_rule_o      (rg2ck_rule           )
); 
endmodule